<template>
  <!-- 我的收藏 -->
  <div class="personCollect">
      <head-usual :title="collect" :to="to"></head-usual> 
    <mt-navbar v-model="type">
      <mt-tab-item id="1">项目</mt-tab-item>
      <mt-tab-item id="2">职位</mt-tab-item>
      <mt-tab-item id="3">筑功者</mt-tab-item>
      </mt-navbar>
            <!-- tab-container -->
    <div  v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="0">
      <mt-tab-container v-model="type" swipeable>
          <mt-tab-container-item id="1" v-if="type==1">
              <!-- 项目列表 -->
              <div class="project-list" v-for="(item,index) in getCollectList" :key="index">
                  <!-- 每一个收藏的项目 -->
                  <div class="project-item">
                      <p>
                          <span>{{item.name}}</span>
                          <span>{{item.status}}</span>
                      </p>
                      <div class="project-item-2">
                          <p class="project-item-type">
                            <svg class="icon price-bottom-01" aria-hidden="true">
                                <use xlink:href="#icon-leixing"></use>
                            </svg>
                            <span>类型：</span>
                            <span>{{item.type}}</span>
                          </p>
                          <p  class="project-item-time">
                            <svg class="icon price-bottom-01" aria-hidden="true">
                                <use xlink:href="#icon-zhouqifuwushiduan"></use>
                            </svg>
                            <span>周期：</span>
                            <span>{{item.duration}}</span>
                          </p>
                          <p class="project-item-price">
                            <span>可议价</span>
                            <span>￥{{item.price}}万元</span>
                          </p>
                      </div>
                      <div class="project-item-3">
                          <p>
                              <span>{{item.hits}}浏览</span>
                              <span class="fenge"></span>
                              <span>{{item.signUpNum}}人报名</span>
                          </p>
                          <p>{{item.addtime}}发布</p>
                      </div>
                      <div class="bianji-2" >
                          <p><router-link :to="'/projects/detail/'+item.id">查看详情</router-link></p>
                          <p @click="HandleRemove(index,item.id,type)">取消收藏</p>
                          <span class="fenge"></span>
                      </div>
                  </div>
              </div>
          </mt-tab-container-item>
          <mt-tab-container-item id="2" v-if="type==2">
            <!-- 职位列表 -->
              <div class="position-item" v-for="(item,index) in getCollectList" :key="index">
                <p class="p1">
                    <span>{{item.name}}</span><span>{{item.lowSalary}}</span>
                </p>
                <p class="p2">
                    <span class="p2-1">{{item.provinces}}</span><span class="fenge"></span>
                    <span class="p2-2">{{item.experience}}</span><span class="fenge"></span>
                    <span class="p2-3">{{item.degree}}</span><span class="fenge"></span>
                    <span>{{item.nature}}</span>
                    <span class="p2-4">{{item.addtime}}</span>
                </p>
                <p class="p3">
                  <span v-for="(tag,index) in item.Arr_tags" :key="index">{{tag}}</span>
                </p>
                <P class="p4"></P>
                <dl class="dl5">
                    <dt><img :src="item.Publisher.headportrait"/></dt>
                    <dd>
                        <p>{{item.Publisher.name}}</p>
                        <p>
                            <span>不需要融资</span>
                            <span class="fenge02"></span>
                            <span>20-150人</span>
                            <span class="fenge02"></span>
                            <span>移动互联网</span>
                        </p>
                    </dd>
                </dl>
                <div class="bianji-2" >
                  <p><router-link :to="'/jobs/detail/'+item.id">查看详情</router-link></p>
                    <p @click="HandleRemove(index,item.id,type)">取消收藏</p>
                    <span class="fenge"></span>
                </div>
              </div>
          </mt-tab-container-item>
          <mt-tab-container-item id="3" v-if="type==3" >
             <div class="classify">
                <div :class="(searchCondition.busCol==''?'active':'')+' classify-item fenge'" @click="handleColletqh('')">我的收藏 </div>
                <div :class="(searchCondition.busCol=='becollected'?'active':'')+' classify-item '" @click="handleColletqh('becollected')">收藏我的 </div>
            </div>
              <!-- 公司列表 -->
              <div class="companyList" v-for="(item,index) in getCollectList" :key="index">
                      <!-- 每条数据 -->
                  <div class="company-list-item">
                      <dl>
                          <dt class="company-dt">
                              <img :src="item.headportrait" />
                              <!-- class="company-dt-img company-img" -->
                          </dt>
                          <dd class="company-dd">
                              <p class="company-dd-p1"><span>{{item.name}}</span><span class="company-p1-right">{{item.str_type}}</span></p>
                              <p class="company-dd-p2">
                                   <span v-for="(tag,index) in item.Arr_tags" :key="index">{{tag}}</span>
                              </p>
                              <p class="company-dd-p3">
                                  <span>浏览量</span>
                                  <span>{{item.hits}}</span>
                                  <span class="p3-fenge"></span>
                                  <span class="fenge-right">好评率</span>
                                  <span>96%</span>
                              </p>
                              <p class="company-dd-p4">
                                  <span class="company-p4-left">{{item.industry}}</span>
                                  <span class="company-p4-right">{{item.introduction}}</span>
                              </p>
                          </dd>
                      </dl>
                      <div class="bianji-2"  >
                          <p><router-link :to="''+item.url+item.id" >查看详情</router-link></p>
                          <p @click="HandleRemove(index,item.id,type)">取消收藏</p>
                          <span class="fenge"></span>
                      </div>
                  </div>
              </div>
          </mt-tab-container-item>
      </mt-tab-container>
        <div v-show="loading" class="page-infinite-loading">
                        <mt-spinner type="fading-circle"></mt-spinner>
                        加载中...
        </div>
        <div v-show="allLoaded" class="page-infinite-data">亲！别拉了我是有底线的</div>
    </div>
  </div>
</template>

<script>
import { Navbar, TabItem , MessageBox} from "mint-ui";
import { GetPageList, Delete } from "@/api/user/collect";
export default {
  data() {
    return {
      collect: "我的收藏",
      to:'/user',
      searchCondition: {
        pageIndex: 1,
        type: "1",
        busCol:""//becollected
      },
      type: "1",
      totalPage: 0,
      loading: false, //是否显示加载中
      allLoaded: true, //加载完毕
      getCollectList: {}
    };
  },
  created() {
    this.Initialization();
  },
  methods: {
    HandleRemove(index, cid, type) {
      //移除某一项
      MessageBox.confirm("确认取消收藏?").then(action => {
        Delete(cid, parseInt(type)).then(res => {
          if (res.Data) {
            this.getCollectList.splice(index, 1);
          } else  this.$toast("取消收藏失败,请刷新重试！"); 
        });
      });
    },
    Initialization() {
      this.$indicator.open();
      setTimeout(() => {
        GetPageList(this.searchCondition).then(res => {
          if (res.StatusCode === 200) {
            this.getCollectList = res.Data;
            this.totalPage = res.TotalPage;
            this.$indicator.close();
          }
          else{
            this.$toast(res.Data);
            setTimeout(res=>{
              this.$indicator.close();
            });
          }
        });
      }, 400);
    },
    loadMore() {
      console.log(this.searchCondition.pageIndex,this.totalPage);
      //分页加载更多
      if (this.searchCondition.pageIndex >= this.totalPage) {
        this.allLoaded = true;
        return;
      }
      this.loading = true;
      setTimeout(() => {
        this.searchCondition.pageIndex++;
        GetPageList(this.searchCondition).then(res => {
          if (res.StatusCode === 200) {
            this.getCollectList = this.getCollectList.concat(res.Data);
          }
        });
        this.loading = false;
      }, 1000);
    },
    //收藏我的切换
    handleColletqh(str){
        this.searchCondition.pageIndex=1;
        this.searchCondition.type=3;
        this.searchCondition.busCol=str;
        this.Initialization();
    }
  },
  watch: {
    type(val, oldVal) {
      this.searchCondition.type = val;
      this.searchCondition.pageIndex=1;
      if (this.type == "2") {
        this.getCollectList = [
          {
            Publisher: { headportrait: "" },
          }
        ];
      }
      this.Initialization();
    }
  },
};
</script>

<style lang="scss" scoped>
.headUsual {
  border-bottom: 1px solid #eeeeee;
}
.collect-hd {
  padding-left: 12px;
  overflow: hidden;
  border-bottom: 10px solid #f4f4f4;
  > p {
    float: left;
    padding-top: 17px;
    padding-bottom: 17px;
    width: 15%;
    font-size: 16px;
    color: #282828;
    border-bottom: 2px solid #ffffff;
    text-align: center;
  }
  .active {
    color: #fd4f00;
    border-bottom: 2px solid #fd4f00;
  }
  .active-last {
    width: 40%;
    text-align: left;
  }
}
// 每一个收藏的项目
.project-item {
  overflow: hidden;
  border-bottom: 10px solid #f4f4f4;
  > :first-child {
    font-size: 16px;
    color: #282828;
    margin-left: 12px;
    margin-right: 12px;
    overflow: hidden;
    margin-bottom: 18px;
    margin-top: 21px;
    > :first-child {
      display: block;
      float: left;
    }
    > :last-child {
      display: block;
      float: right;
      color: #ffffff;
      font-size: 12px;
      padding: 0px 8px;
      background: #3887fe;
      border-radius: 9px;
      margin-top: 2.5px;
    }
    .doing {
      background: #fd4f00;
    }
    .done {
      background: #999999;
    }
  }
    .project-item-2{
    overflow: hidden;
    margin-left: 12px;
    margin-right: 12px;
    color: #999999;
      .project-item-type {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
          > :last-child {
            color: #666666;
          }
          .icon{
            margin-right: 7.5px;
          }
    }
      .project-item-time {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
          > :last-child {
            color: #666666;
          }
           .icon{
            margin-right: 7.5px;
          }
    }
    .project-item-price {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      > :first-child {
        color: #999999; 
        margin-right: 8px;
      }
      > :last-child {
        color: #fd4f00;
        font-size: 16px;
      }
    }
  }
  .project-item-3 {
    overflow: hidden;
    margin-left: 12px;
    margin-right: 12px;
    color: #999999;
    margin-bottom: 21px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    > :first-child {
      display: flex;
      align-items: center;
      > span {
        display: block;
        float: left;
      }
      > .fenge {
        width: 1px;
        height: 11px;
        background: #999999;
        display: block;
        float: left;
        margin-left: 9px;
        margin-right: 9px;
      }
    }
    
  }
 
}
// 攻略页
.gonglue-item {
  width: 100%;
  border-top: 10px solid #f4f4f4;
  position: relative;
  margin-top: 2px;
  // background: -webkit-linear-gradient( top, gray); /* Safari 5.1 - 6.0 */
  // background: linear-gradient(to bottom , white); /* 标准的语法（必须放在最后） */
  > img {
    width: 414px;
    height: 200px;
  }
  .hidder {
    width: 100%;
    height: 200px;
    background: -webkit-linear-gradient(
      top,
      black,
      white
    ); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(
      bottom,
      black,
      white
    ); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(
      bottom,
      black,
      white
    ); /* Firefox 3.6 - 15 */
    background: linear-gradient(to bottom, black, white);
    /* 标准的语法（必须放在最后） */
    position: absolute;
    top: 0px;
    z-index: 2;
    opacity: 0.1;
  }
  .p-left {
    position: absolute;
    left: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
  }
  .p-right {
    position: absolute;
    right: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
    > span {
      float: left;
      display: block;
    }
    > .icon {
      display: block;
      float: left;
      margin-top: 3px;
      margin-right: 8px;
    }
  }
  // 播放按钮
  .bofang-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -27px;
    margin-top: -42px;
    background: rgba(40, 40, 40, 0.5);
    > .sanjiao {
      width: 0;
      height: 0;
      border-top: 15px solid transparent;
      border-bottom: 15px solid transparent;
      border-left: 30px solid #ffffff;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      margin: auto;
      margin-left: 16px;
    }
  }
  
}
.mint-navbar .mint-tab-item.is-selected {
  border-bottom: 2px solid #fd4f00;
  color: #df4f00;
  margin-bottom: -2px;
}
.mint-tab-item .mint-tab-item-label {
  font-size: 16px !important;
  color: #282828;
}
@media screen and (max-width: 361px) {
  .company-dd-p2 > span {
    margin-right: 5px !important;
  }
  .company-dd-p3 > span {
    margin-right: 3px !important;
  }
  .fenge-right {
    margin-left: 10px !important;
  }
}
.compangyList {
  position: relative;
}
.company-list-item {
  width: 100%;
  padding-bottom: 16.3px;
  border-bottom: 10px solid rgb(238, 238, 238);
}
.company-list-item > dl {
  overflow: hidden;
}
.company-dt {
  width: 74.6px;
  height: 74.6px;
  background: #ff6900;
  overflow: hidden;
  float: left;
  margin-top: 16.3px;
  margin-left: 12px;
}
/* 保持图片不失真 */
.company-img {
  width: 64.3px;
  height: 33.3px;
  display: block;
  margin-top: 20.65px;
  margin-left: 5.15px;
}
.person-img {
  width: 100%;
  height: 100%;
}
.company-dd {
  float: left;
  margin-left: 11.6px;
  margin-top: 16.3px;
}
.company-dd-p1 {
  font-size: 16px;
  color: #282828;
  margin-bottom: 11.66px;
  overflow: hidden;
}
.company-dd-p1 > span {
  display: block;
  float: left;
}
.company-p1-right {
  display: inline-block;
  font-size: 12px;
  float: left;
  color: #ffffff;
  background: #fd4f00;
  padding: 2.5px 4px;
  margin-left: 7px;
}
.person-fenge {
  width: 0;
  height: 10px;
  border: 1px solid rgb(40, 40, 40);
  display: inline-block;
  margin-left: 13px;
  margin-right: 13px;
}
.company-dd-person {
  background: rgb(56, 135, 254) !important;
  margin-left: 7px;
}
.company-dd-p2 {
  margin-bottom: 12px;
  height: 28.666px;
}
.company-dd-p2 > span {
  display: block;
  float: left;
  color: #fd4f00;
  font-size: 14px;
  margin-right: 10px;
  padding: 2px 3px;
  border: 1px solid #fd4f00;
}
.company-p2-last {
  margin-right: 0px !important;
}
.company-dd-p3 {
  font-size: 12px;
  color: #999999;
  height: 11.3px;
  margin-bottom: 13px;
}
.company-dd-p3 > span {
  float: left;
  color: #666666;
  display: block;
  margin-right: 4px;
  line-height: 9.81px;
  font-size: 12px;
}
.p3-fenge {
  display: block;
  float: left;
  width: 0px;
  height: 8px;
  border: 1px solid #999999;
  margin-left: 10px !important;
  margin-right: 15px !important;
}
.company-dd-p4 {
  overflow: hidden;
  margin-bottom: 14px;
}
.company-p4-left {
  display: block;
  float: left;
  font-size: 12px;
  color: #fff;
  padding: 3.5px 2.6px;
  background: rgb(255, 186, 0);
  max-width: 53px;
  max-height: 24px;
}
.company-p4-right {
  display: block;
  float: left;
  font-size: 12px;
  color: rgb(102, 102, 102);
  margin-left: 6.66px;
  line-height: 20px;
  width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3.15px;
}
// 攻略技能栏
// 攻略页
.gonglue-list {
  padding: 5px 6px;
  background: #f4f4f4;
  padding-bottom: 75px;
  margin-top: 2px;
}
.gonglue-item {
  width: 100%;
  position: relative;
  margin-top: 10px;
  border-radius: 3%;
  border: 1px solid transparent;
  background: #ffffff;
  // background: -webkit-linear-gradient( top, gray); /* Safari 5.1 - 6.0 */ // background: linear-gradient(to bottom , white); /* 标准的语法（必须放在最后） */
  .item-img {
    width: 100%;
    height: 200px;
    > img {
      max-width: 100%;
      max-height: 100%;
      vertical-align: middle;
      border: 1px solid transparent;
      border-top-left-radius: 3%;
      border-top-right-radius: 3%;
      // border-radius: 5%;
    }
  }
  .hidder {
    width: 100%;
    height: 194px;
    background: -webkit-linear-gradient(top, black, white);
    /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(
      bottom,
      black,
      white
    ); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(
      bottom,
      black,
      white
    ); /* Firefox 3.6 - 15 */
    background: linear-gradient(
      to bottom,
      black,
      white
    ); /* 标准的语法（必须放在最后） */
    position: absolute;
    top: 0px;
    z-index: 2;
    opacity: 0.1;
    border-radius: 3%;
    border: 1px solid transparent;
  }
  .p-left {
    position: absolute;
    left: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
  }
  .p-right {
    position: absolute;
    right: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
    > span {
      float: left;
      display: block;
    }
    > .icon {
      display: block;
      float: left;
      margin-top: 3px;
      margin-right: 8px;
    }
  }
  // 播放按钮
  .bofang-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -27px;
    margin-top: -42px;
    background: rgba(40, 40, 40, 0.5);
    > .sanjiao {
      width: 0;
      height: 0;
      border-top: 15px solid transparent;
      border-bottom: 15px solid transparent;
      border-left: 30px solid #ffffff;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      margin: auto;
      margin-left: 16px;
    }
  }
  .bianji-2 {
    overflow: hidden;
    font-size: 16px;
    color: #999999;
  }
}
.collect-load {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 9px;
  .icon {
    margin: 0 10px;
  }
}
.collect-time {
  text-align: left;
  padding-left: 9px;
}
// 职位列表
.position-item {
  display: block;
  padding-left: 11px;
  padding-right: 11px;
  border-bottom: 8.3px solid #f4f4f4;
  // 第一行
  .p1 {
    overflow: hidden;
    margin-bottom: 12px;
    margin-top: 16px;
    > :first-child {
      color: #999999;
      font-size: 16px;
      display: block;
      float: left;
    }
    .p1-bolder {
      color: #282828;
    }
    > :last-child {
      color: #999999;
      font-size: 14px;
      display: block;
      float: right;
      margin-right: 12px;
    }
  } // 第二行
  .p2 {
    overflow: hidden;
    margin-bottom: 13px;
    display: flex;
    align-items: center;
    > span {
      display: block;
      float: left;
      color: #666666;
      font-size: 12px;
    }
    .p2-1 {
      margin-right: 9px;
    }
    .p2-2 {
      margin-right: 9px;
    }
    .p2-3 {
      margin-right: 9px;
    }
    .fenge {
      width: 0px;
      height: 12px;
      border: 1px solid #666666;
      margin-right: 10px;
    }
    .p2-4 {
      float: right;
      margin-right: 12px;
    }
  }
  // 第三行
  .p3 {
    > span {
      font-size: 10px;
      color: #999999;
      padding: 5.3px 8.16px;
      border: 1px solid transparent;
      background: #f3f3f3;
      display: inline-block;
      margin-right: 11px;
    }
  }
  // 第四行虚线
  .p4 {
    height: 0px;
    margin: 12px auto;
    border: 1px dashed #eeeeee;
  }
  // 第五个dl列表
  .dl5 {
    overflow: hidden;
    height: 55px;
    margin: 0;
    // 图片设置
    > dt {
      width: 40px;
      min-height: 40px;
      float: left;
      display: flex;
      align-items: center;
      > img {
        width: 100%;
        max-width: 100%;
        height: auto;
        display: block;
      }
    }
    > dd {
      float: left;
      margin-left: 14px;
      > p {
        color: #999999;
        font-size: 14px;
        margin: 0;
      }
      :first-child {
        color: #282828;
        font-size: 14px;
        margin-bottom: 3px;
      }
      :last-child {
        overflow: hidden;
        > span {
          margin-bottom: 0;
          font-size: 12px;
          color: #999999;
          display: block;
          float: left;
        }
        .fenge02 {
          width: 1px;
          height: 11px;
          border: 1px solid #999999;
          margin-top: 3.51px;
          margin-left: 11px;
          margin-right: 11px;
        }
      }
    }
  }
}
.salary-add {
  color: #fd4f00 !important;
}
 .bianji-2 {
    width: 100%;
    display: flex;
    text-align: center;
    height: 44.6px;
    border-top: 1px solid #f4f4f4;
    > p {
      width: 50%;
      height: 44.6px;
      line-height: 44.6px;
      font-size: 16px;
      a{
        display: block;
        width: 100%;
        height: 100%;
        color: #3887fe;
      }
    }
    > :nth-child(2) {
      color: #999999;
    }

    .fenge {
      width: 1.5px;
      height: 15px;
      background: #eeeeee;
      position: absolute;
      left: 50%;
      margin-top: 14.795px;
    }
  }
  .classify{
    display: flex;
    height: 50px;
    align-items: center;
    border-bottom: 1px solid #dcdcdc;
    .classify-item{
      flex:0 0 50%;
      text-align: center;
      font-size: 14px;
      position: relative;
    }
    .fenge::after{
      content: "";
      width: 2px;
      height: 16px;
      position: absolute;
      right: 0;
      top: 50%;
      margin-top:-8px;
      background: #999;
    }
    .active{
      color:#fd4f00;
    }
  }
</style>
